home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
kermit.columbia.edu
/
kermit.columbia.edu.tar
/
kermit.columbia.edu
/
newsgroups
/
misc.20020314-20021006
/
000416_fdc@columbia.edu_Tue Oct 1 15:32:50 EDT 2002.msg
< prev
next >
Wrap
Text File
|
2002-10-06
|
2KB
|
88 lines
Article: 13752 of comp.protocols.kermit.misc
Path: newsmaster.cc.columbia.edu!news.columbia.edu!news-not-for-mail
From: fdc@columbia.edu (Frank da Cruz)
Newsgroups: comp.protocols.kermit.misc
Subject: Re: Return Value from User Defined Function
Date: 1 Oct 2002 15:31:19 -0400
Organization: Columbia University
Lines: 71
Message-ID: <anct67$ns6$1@watsol.cc.columbia.edu>
References: <ancqme$2980$1@msunews.cl.msu.edu>
NNTP-Posting-Host: watsol.cc.columbia.edu
X-Trace: newsmaster.cc.columbia.edu 1033500680 1005 128.59.39.139 (1 Oct 2002 19:31:20 GMT)
X-Complaints-To: postmaster@columbia.edu
NNTP-Posting-Date: 1 Oct 2002 19:31:20 GMT
Xref: newsmaster.cc.columbia.edu comp.protocols.kermit.misc:13752
In article <ancqme$2980$1@msunews.cl.msu.edu>,
Robert Gibbens <rgibbens@redskytech.com> wrote:
: How would I go about evaluating the return value from a User defined
: function?
: For example, I have the function
:
: DEFINE mlChangePassword {
: (Do something)
: IF FAILURE {
: return 1
: }
: else
: {
: return 0
: }
: }
:
If all you want to do is return success or failure, you would use END rather
than RETURN:
DEFINE mlChangePassword {
(Do something)
IF FAILURE {
end 1
} else {
end 0
}
}
Then you can test the macro invocation with IF SUCCESS / FAILURE:
mlChangePassword someargs...
if fail exit 1 "Password change failed"
If you want a macro to return an arbitrary value, rather than just succeed
or fail, use the RETURN statement. The return value can be a number, a
string, whatever. The caller can access the RETURN value in the \v(return)
variable.
You can also access a macro's return value directly if you invoke it as
a user-defined function:
.somevariable := \fexecute(macroname args)
For example:
define addemup {
local \%i \%s
.\%s := 0
for \%i 1 \v(argc)-1 1 {
increment \%s \&_[\%i]
}
return \%s
}
.sum = \fexecute(addemup 1 2 3 4)
echo \m(sum)
which prints:
10
The script language is documented in "Using C-Kermit":
http://www.columbia.edu/kermit/ck60manual.html
as amplified by the update notes for versions 7 and 8:
http://www.columbia.edu/kermit/ckermit70.html
http://www.columbia.edu/kermit/ckermit80.html
- Frank